package com.iafe.servodroid;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.SeekBar;
import android.widget.TextView;

public class MainActivity extends Activity {

	private static MainActivity instance;
	private SeekBar angleBar;
	// Agrego comentario solo para probar el SVN
	
	/**********************************************************/	
	public static MainActivity getInstance() {
		return instance;
	}
	
	/**********************************************************/	
	public SeekBar getAngleBar() {
		if (angleBar == null) {
			angleBar = (SeekBar) findViewById(R.id.angleBar);
			angleBar.setOnSeekBarChangeListener(Controller.getInstance());
		}
		return angleBar;
	}
	
	/**********************************************************/	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		instance = this;
		setContentView(R.layout.activity_main);
		getAngleBar();
		findViewById(R.id.buttonConnection).setOnClickListener(Controller.getInstance());
		findViewById(R.id.buttonSend).setOnClickListener(Controller.getInstance());
	}

	/**********************************************************/	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	/**********************************************************/	
	public void setAngle(int value) {
		TextView t = (TextView) findViewById(R.id.angleTextView);
		t.setText(String.valueOf(value));
	}

	/**********************************************************/	
	public int getAngleValue() {
		return getAngleBar().getProgress();
	}

}
